package 多态性;
/*
* 多态性的使用
* */
public class AnimalTest {
    public static void main(String[] args) {
        AnimalTest animal=new AnimalTest();
        animal.func(new Dog());//多态性
    }
    public void func(Animal animal){//声明的Animal animal=new Dog();
        animal.eat();
        animal.shout();
    }

}
class Animal{
    public void eat(){
        System.out.println("动物，进食");
    }
    public void shout(){
        System.out.println("动物 隐隐狂吠");
    }
}
class Dog extends Animal{
    public void eat(){
        System.out.println("狗 吃 骨 头");
    }
    public void shout(){
        System.out.println("汪 往 汪");
    }
}
class Cat extends Animal{
    public void eat(){
        System.out.println("猫吃鱼");
    }
    public void shout(){
        System.out.println(" 喵， 喵 喵");
    }
}